package cn.edu.nuaa.springmvc.controller;

import cn.edu.nuaa.springmvc.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "/forward")
public class ForwardController {
    @RequestMapping(value = "/tonewpage")
    public String toNewPage() {
        return "forward:newforward.jsp";
    }

    @RequestMapping(value = "/tonewmodel")
    public ModelAndView toNewModel(@ModelAttribute @RequestBody User user) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("user", user);
        modelAndView.setViewName("newforward02");
        return modelAndView;
    }
}
